home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1013 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: wald@theory.lcs.mit.edu (David Wald)
  3. Newsgroups: comp.std.c++
  4. Subject: cv-quals in template arguments
  5. Date: 9 Apr 1996 14:53:50 GMT
  6. Organization: Theory of Computation, LCS, MIT
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <WALD.96Apr9105559@woodpecker.lcs.mit.edu>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. X-Nntp-Posting-Host: woodpecker.lcs.mit.edu
  11. Content-Length: 841
  12. X-Lines: 24
  13. Originator: clamage@taumet
  14.  
  15. What should a compiler do with the following code?
  16.  
  17.   template <class T> T f(const T* p) {
  18.       return *p;
  19.   }
  20.  
  21.   int foo(int* pi, const int* pci)
  22.   {
  23.      return f(pi) + f(pci);
  24.   }
  25.  
  26. Reading from the April'95 draft, it's clear that both calls to f
  27. should resolve to f(const int*), as in the example in 14.10.2.14.
  28. What's not clear to me is if both calls have the same return type.  At
  29. least one compiler around here complains that we've (implicitly)
  30. provided two definitions of f(const int*), one returning int and one
  31. returning const int.  Can someone please quote me chapter and verse
  32. on this?
  33.  
  34. -David
  35. -- 
  36. ============================================================================
  37. David Wald      http://theory.lcs.mit.edu/~wald/     wald@theory.lcs.mit.edu
  38. ============================================================================
  39.  
  40.  
  41. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  42. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  43. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  44. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  45. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  46.